<?php

/*
 * to add the new user to users table
 */

class Lognew_Model extends Model {

    public function __construct() {
        parent::__construct();
    }

    public function game() {
        $uname = $_POST['login'];

        $upassword = $_POST['password'];

        $sth = $this->db->prepare("INSERT INTO users (login, password) 
                    VALUES (:login ,MD5(:password));
                ");
        $sth->execute(array(
            ':login' => $uname,
            ':password' => $upassword
        ));
        
        Session::init();
        Session::set('loggedIn', true);
        //Store the user namsessione in the 
        $_SESSION['username'] = $uname;
        $_SESSION['fenrty']=0;
        //redirect user to the game page
        header('location: ../game');
    }

}